const fs = require('fs');
const path = require('path');
let data = fs.readFileSync(path.resolve(__dirname, './demo1.pegjs'), 'utf-8');
const peggy = require("peggy");
const parser = peggy.generate(data);
let txt = fs.readFileSync(path.resolve(__dirname, './demo1.txt'), 'utf-8');
let res=parser.parse(txt)
res=JSON.stringify(res,null,4)
fs.writeFileSync(path.resolve(__dirname, './demo1.out'),res);
console.log(res);